class Solution
{
public:
    string getHint(string secret, string guess)
    {
        vector<int> sCount(10, 0);
        vector<int> gCount(10, 0);
        int a = 0;
        int b = 0;
        int n = secret.size();
        for (int i = 0; i < n; ++i)
        {
            if (secret[i] == guess[i])
            {
                ++a;
            }
            else
            {
                ++sCount[secret[i] - '0'];
                ++gCount[guess[i] - '0'];
            }
        }
        for (int i = 0; i < 10; ++i)
        {
            b += min(sCount[i], gCount[i]);
        }
        return to_string(a) + "A" + to_string(b) + "B";
    }
};